//
// Created by libtity on 7/2/24.
//

#ifndef COMPLIER_COMPLIER_H
#define COMPLIER_COMPLIER_H

#include "bits/stdc++.h"
#include <cstdio>

using namespace std;

#define INF 2147483647

#define NUMBER   1
#define WORD     2
#define WHITE    3
#define COMMENT  4
#define HUANHANG 5
#define STRING   6
#define FENHAO   7
#define JIEFU    8

class Compiler
{
private:
    FILE*    fp1;
    ofstream fp2;
    int current_line;
    char   input[200];
    string token;
    int    index;
    string word;
    int    num;
    char   c;

    vector<string> reserved = {"main", "const", "int", "break", "continue", "if", "else", "while", "void", "return"};
    vector<char>   jiefu    = {'+', '-', '*', '(', ')', '{', '}', '[', ']', ';', ',', '<', '>', '=', '!', '&', '|'};

    int table[256];

public:
    void compile(const char* path);

    void scanner();

private:
    void   deleteComment();
    void   getToSpace();
    void   getString();
    void   initTable();
    string upper(string s);
};


#endif   // COMPLIER_COMPLIER_H
